package cate.game.role.farm;

import cate.game.fight.task.FightTask;
import cate.game.role.FuncOpenChecker;
import cate.game.role.Role;
import easy.java.dev.note.NoteField;

public abstract class AbstractFarm extends FuncOpenChecker implements IFarm{
    @NoteField(value = "是否正在战斗")
    public boolean fighting;

    @Override
    public void initialize(Role role) {
        super.initialize(role);
        FightTask task = role.getGame().fight.task.getTask(role, getFightFuncId());
        fighting = task != null && !task.invalid();
    }

    @Override
    public void onEnter(){
        super.onEnter();
        FightTask task = role.getGame().fight.task.getTask(role, getFightFuncId());
        fighting = task != null && !task.invalid();
    }

    @Override
    public boolean isFighting(){
        return fighting;
    }

    @Override
    public void startFighting(){
        fighting = true;
    }

    @Override
    public void endFighting(){
        fighting = false;
    }

}
